/*
 * cpu.h
 *
 *  Created on: Mar 10, 2012
 *      Author: our_beastie
 */

#ifndef CPU_H_
#define CPU_H_


#include "timer.h"
#include "io.h"
#include "scheduler.h"
#include "sharedmemory.h"
#include "printer.h"
#include "sleep.h"

#define MAX_PROCESSES 100
#define DEFAULT_PAUSE 10000
#define CPU_PAUSE 1;

#define NUM_IO 2



typedef struct {
	pthread_mutex_t lock;
	int cpu_pause;
	Timer timer;
	IODevice io[NUM_IO];
	int pc;
	Memory memory;
	Scheduler sched;
	Queue block_queue[NUM_IO];
	Process* process;
	Printer printer;
	int num_processes;

} CPUStr;

typedef CPUStr* CPU;

CPU newCPU(int num_ui, int num_calc, int num_prod, int num_cons, int scheduler_type);
void runCPU(const CPU cpu);

#endif /* CPU_H_ */
